package com.nut.service.impl;

import com.nut.entity.Article;
import com.nut.entity.User;
import com.nut.mapper.ArticleMapper;
import com.nut.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ author : HyoJoo-W
 * @ createDate : 2021-04-23 13:41
 * @ Description : 文章实现类
 */
@Service
@Transactional
public class ArticleServiceImpl implements ArticleService
{
    @Autowired
    private ArticleMapper articleMapper;

    /**
     * @Description 查询指定用户的所有文章
     * @param user: 指定User
     * @return java.util.List<com.nut.entity.Article>
     **/
    @Override
    public List<Article> findAllArticles(User user)
    {
        return articleMapper.findAll(user);
    }

    @Override
    public void addArticle(Article article)
    {
        articleMapper.add(article);
    }

    @Override
    public void deleteArticleById(int id)
    {
        articleMapper.delete(id);
    }

    @Override
    public void updateArticleById(Article article)
    {
        articleMapper.update(article);
    }
}
